﻿using System.Data;
using System.Data.Common;
using System.Web;
using System.Web.Caching;

namespace NTL.DAL
{
	public abstract class DataAccess
	{
		private string _connectionString = "";
		private bool _enableCaching = true;
		private int _cacheDuration = 0;

		protected string ConnectionString { get { return _connectionString; } set { _connectionString = value; } }
		protected bool EnableCaching { get { return _enableCaching; } set { _enableCaching = value; } }
		protected int CacheDuration { get { return _cacheDuration; } set { _cacheDuration = value; } }

		protected Cache Cache { get { return HttpContext.Current.Cache; } }

		protected int ExecuteNonQuery(DbCommand cmd) { return cmd.ExecuteNonQuery(); }
		protected IDataReader ExecuteReader(DbCommand cmd) { return ExecuteReader(cmd, CommandBehavior.Default); }
		protected IDataReader ExecuteReader(DbCommand cmd, CommandBehavior behavior) { return cmd.ExecuteReader(behavior); }
		protected object ExecuteScalar(DbCommand cmd) { return cmd.ExecuteScalar(); }
	}
}